<template>
  <div>
    <!-- 搜索栏区域 -->
    <el-card class="SearchCard" body-style="padding:0px">
      <el-row>
        <el-col :span="2">
          <div class="SearchTitle">条件搜索栏</div>
        </el-col>
        <el-col :span="4">
          <el-row>
            <el-col :span="10">
              <div class="SearchLable">搜索关键字</div>
            </el-col>

            <el-col :span="14">
              <div class="SearchLable">
                <el-input placeholder="请输入内容" v-model="queryInfo.srm" clearable></el-input>
              </div>
            </el-col>
          </el-row>
        </el-col>
        <el-col :span="2">
          <div class="SearchLable">
            <el-button size="medium" type="primary" @click="getdictDrugList()">搜索</el-button>
          </div>
        </el-col>
        <el-col :span="2">
          <div class="SearchLable">
            <el-button size="medium" type="primary" @click="addDrugVisible = true">添加新药</el-button>
          </div>
        </el-col>
      </el-row>
    </el-card>
    <el-card class="TableCard" :body-style="{ padding: '0px' }">
      <div>
        <el-table
          :data="dictDrugList"
          border
          :header-cell-style="{ 'text-align':'center',background: '#3F9DFD', color: '#FFF' }"
          :cell-style="{'text-align':'center'}"
          size="medium"
          stripe
          ref="table"
          :height="tableHeight"
          style="width: 100%;font-size:12px"
        >
          <el-table-column prop="drugCode" label="药品编码" width="72"></el-table-column>
          <el-table-column prop="name" label="操作" width="120">
            <template slot-scope="scope">
              <el-button type="text" size="mini" @click="showDrugOne(scope.row.id)">查看</el-button>
              <el-button
                type="text"
                size="mini"
                @click="deleteDictDrugOne(scope.row.id)"
                style="margin-left:5px"
              >删除</el-button>
            </template>
          </el-table-column>
          <el-table-column prop="drugName" width="150" label="药品名称"></el-table-column>
          <el-table-column prop="cbrand" label="商品名"></el-table-column>
          <el-table-column label="药品类型" width="72">
            <template slot-scope="scope">
              <div v-if="scope.row.nameType==8">西药</div>
              <div v-else-if="scope.row.nameType==2">草药</div>
              <div v-else-if="scope.row.nameType==6">中成药</div>
            </template>
          </el-table-column>
          <!-- <el-table-column prop="genName" label="药品成分"></el-table-column> -->
          <el-table-column prop="formName" label="剂型名称" width="72"></el-table-column>
          <el-table-column prop="drugSpec" label="药品规格"></el-table-column>

          <el-table-column prop="compName" label="生产厂家"></el-table-column>
          <el-table-column prop="approvalCode" label="批准文号"></el-table-column>
          <el-table-column prop="doseUnit" label="给药单位" width="72"></el-table-column>

          <el-table-column label="是否溶剂" width="72">
            <template slot-scope="scope">
              <!-- {{scope.row.isSolvent}} -->
              {{(scope.row.isSolvent==0)?"否":(scope.row.isSolvent==1)?"是":(scope.row.isSolvent==-1)?"未知":""}}
              <!-- <div v-if="scope.row.isSolvent==0">否</div>
              <div v-else-if="scope.row.isSolvent==1">是</div>
              <div v-else-if="scope.row.isSolvent==-1">未知</div>-->
            </template>
          </el-table-column>
          <el-table-column label="是否注射液" width="82">
            <template slot-scope="scope">
              <!-- {{scope.row.isInject}} -->
              {{(scope.row.isInject==0)?"否":(scope.row.isInject==1)?"是":(scope.row.isInject==-1)?"未知":""}}
              <!-- <div v-if="scope.row.isInject==0">否</div>
              <div v-else-if="scope.row.isInject==1">是</div>
              <div v-else-if="scope.row.isInject==-1">未知</div>-->
            </template>
          </el-table-column>
          <el-table-column label="TPN属性标记">
            <template
              slot-scope="scope"
            >{{(scope.row.tpn==0)?"不属于TPN药品":(scope.row.tpn==1)?"脂肪乳":(scope.row.tpn==2)?"氨基酸":(scope.row.tpn==3)?"氨基酸+脂肪乳":(scope.row.tpn==4)?"糖":(scope.row.tpn==5)?"糖+脂肪乳":(scope.row.tpn==6)?"糖+氨基酸":(scope.row.tpn==7)?"糖+氨基酸+脂肪乳":""}}</template>
          </el-table-column>
        </el-table>
      </div>
      <div class="block">
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="queryInfo.pagenum"
          :page-sizes="[20, 50, 100]"
          :page-size="queryInfo.pageSize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="this.total"
          background
        ></el-pagination>
      </div>
    </el-card>
    <!-- 新增药品 -->
    <el-dialog
      title="新增药品字典"
      :visible.sync="addDrugVisible"
      width="50%"
      :before-close="handleClose"
    >
      <div>
        <el-card class="box-card showOneData">
          <el-form ref="form" :model="addDrugData" label-width="110px" inline>
            <el-form-item label="药品名称">
              <el-input v-model="addDrugData.drugName"></el-input>
            </el-form-item>
            <el-form-item label="药品类型">
              <el-select v-model="addDrugData.nameType">
                <el-option
                  v-for="item in Typeoptions"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                ></el-option>
                <!-- <el-option label="西药" value="8"></el-option>
                <el-option label="中药" value="2"></el-option>
                <el-option label="中成药" value="6"></el-option>-->
              </el-select>
            </el-form-item>
            <el-form-item label="商品名">
              <el-input v-model="addDrugData.cbrand"></el-input>
            </el-form-item>
            <el-form-item label="药品成分">
              <el-input v-model="addDrugData.genName">
                <el-button slot="append" @click="ShowComp(1)">选择成分</el-button>
              </el-input>
            </el-form-item>
            <el-form-item label="成分ID">
              <el-input v-model="addDrugData.genId"></el-input>
            </el-form-item>

            <el-form-item label="剂型名称">
              <el-input v-model="addDrugData.formName">
                <el-button slot="append" @click="ShowDosage(1)">选择剂型</el-button>
              </el-input>
            </el-form-item>
            <el-form-item label="药品规格">
              <el-input v-model="addDrugData.drugSpec"></el-input>
            </el-form-item>
            <el-form-item label="生产厂家">
              <el-input v-model="addDrugData.compName"></el-input>
            </el-form-item>
            <el-form-item label="生产厂家编码">
              <el-input v-model="addDrugData.compId"></el-input>
            </el-form-item>
            <el-form-item label="批准文号">
              <el-input v-model="addDrugData.approvalCode"></el-input>
            </el-form-item>
            <el-form-item label="给药单位">
              <el-input v-model="addDrugData.doseUnit"></el-input>
            </el-form-item>
            <el-form-item label="是否溶剂">
              <!-- <el-input v-model="addDrugData.isSolvent"></el-input> -->
              <el-select v-model="addDrugData.isSolvent">
                <el-option
                  v-for="item in InjectOptions"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                ></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="是否注射液">
              <!-- <el-input v-model="addDrugData.isInject"></el-input> -->
              <el-select v-model="addDrugData.isInject">
                <el-option
                  v-for="item in InjectOptions"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                ></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="TPN属性标记">
              <!-- <el-input v-model="ShowOneData.tpn"> -->
              <el-select v-model="addDrugData.tpn">
                <el-option
                  v-for="item in TPNOptions"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-form>
        </el-card>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="addDrug()">新 增</el-button>
        <el-button @click="addDrugVisible = false">取 消</el-button>
      </span>
    </el-dialog>
    <el-dialog
      title="查看药品字典"
      :visible.sync="ShowOneDataVisible"
      width="50%"
      :before-close="handleClose"
    >
      <div>
        <el-card class="box-card showOneData">
          <el-form ref="form" :model="ShowOneData" label-width="110px" inline>
            <el-form-item label="药品名称">
              <el-input v-model="ShowOneData.drugName"></el-input>
            </el-form-item>
            <el-form-item label="药品类型">
              <el-select v-model="ShowOneData.nameType">
                <el-option
                  v-for="item in Typeoptions"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                ></el-option>
                <!-- <el-option label="西药" value="8"></el-option>
                <el-option label="中药" value="2"></el-option>
                <el-option label="中成药" value="6"></el-option>-->
              </el-select>
            </el-form-item>
            <el-form-item label="商品名">
              <el-input v-model="ShowOneData.cbrand"></el-input>
            </el-form-item>
            <el-form-item label="药品成分">
              <el-input v-model="ShowOneData.genName">
                <el-button slot="append" @click="ShowComp(2)">选择成分</el-button>
              </el-input>
            </el-form-item>
            <el-form-item label="成分ID">
              <el-input v-model="ShowOneData.genId"></el-input>
            </el-form-item>

            <el-form-item label="剂型名称">
              <el-input v-model="ShowOneData.formName">
                <el-button slot="append" @click="ShowDosage(2)">选择剂型</el-button>
              </el-input>
            </el-form-item>
            <el-form-item label="药品规格">
              <el-input v-model="ShowOneData.drugSpec"></el-input>
            </el-form-item>
            <el-form-item label="生产厂家">
              <el-input v-model="ShowOneData.compName"></el-input>
            </el-form-item>
            <el-form-item label="生产厂家编码">
              <el-input v-model="ShowOneData.compId"></el-input>
            </el-form-item>
            <el-form-item label="批准文号">
              <el-input v-model="ShowOneData.approvalCode"></el-input>
            </el-form-item>
            <el-form-item label="给药单位">
              <el-input v-model="ShowOneData.doseUnit"></el-input>
            </el-form-item>
            <el-form-item label="是否溶剂">
              <!-- <el-input v-model="ShowOneData.isSolvent"></el-input> -->
              <el-select v-model="ShowOneData.isSolvent">
                <el-option
                  v-for="item in InjectOptions"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                ></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="是否注射液">
              <!-- <el-input v-model="ShowOneData.isInject"></el-input> -->
              <el-select v-model="ShowOneData.isInject">
                <el-option
                  v-for="item in InjectOptions"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                ></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="TPN属性标记">
              <!-- <el-input v-model="ShowOneData.tpn"> -->
              <el-select v-model="ShowOneData.tpn">
                <el-option
                  v-for="item in TPNOptions"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-form>
        </el-card>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="updateDrugOne()">更 新</el-button>
        <el-button @click="ShowOneDataVisible = false">取 消</el-button>
      </span>
    </el-dialog>
    <!-- 剂型 -->
    <el-dialog
      title="选择剂型"
      :visible.sync="ShowDosageVisible"
      class="editDialog"
      width="30%"
      :before-close="handleClose"
    >
      <div style="width:100%;height:527px">
        <div class="addInput">
          <el-input v-model="DosageData.srm" size="small" placeholder="请输入内容"></el-input>
          <el-button style="margin-right:8px" type="primary" size="small" @click="SearchDrug()">搜索</el-button>
        </div>
        <el-table
          :data="DosageData.DosageTableData"
          stripe
          border
          height="400"
          style="width: 100%;font-size: 10px"
          :header-cell-style="{'text-align':'center'}"
          :row-style="{height:'40px'}"
          :cell-style="{'text-align':'center',padding:'0px'}"
          ref="todoListRef"
          @row-click="handleRow"
          @selection-change="handleSelectionChange"
        >
          >
          <el-table-column label width="35">
            <template slot-scope="scope">
              <el-radio :label="scope.row" v-model="DosageData.selectDosage">&nbsp;</el-radio>
            </template>
          </el-table-column>

          <el-table-column prop="formId" width="80" label="剂型ID"></el-table-column>
          <el-table-column prop="formName" label="剂型名称"></el-table-column>
          <el-table-column prop="formSearchCode" label="剂型搜索码"></el-table-column>
        </el-table>
        <!-- <el-pagination background layout="prev, pager, next" :total="1000"></el-pagination> -->
        <div class="dialogBlock">
          <el-pagination
            @size-change="handleSizeChange3"
            @current-change="handleCurrentChange3"
            current-page.sync="1"
            :page-size="100"
            layout="total, prev, pager, next"
            :total="DosageData.total"
          ></el-pagination>
        </div>
        <span slot="footer" class="dialog-footer">
          <div class="SortFoot">
            <el-button
              style="margin-right:8px"
              type="primary"
              size="small"
              @click="SelectDoseID()"
            >确定</el-button>
            <el-button style="margin-right:8px" @click="CodeSelectVisible = false" size="small">取消</el-button>
          </div>
        </span>
      </div>
    </el-dialog>
    <!-- 成分 -->
    <el-dialog
      title="选择成分"
      :visible.sync="ShowCompVisible"
      class="editDialog"
      width="30%"
      :before-close="handleClose"
    >
      <div style="width:100%;height:527px">
        <div class="addInput">
          <el-input v-model="CompData.srm" size="small" placeholder="请输入内容"></el-input>
          <el-button style="margin-right:8px" type="primary" size="small" @click="SearchDrug()">搜索</el-button>
        </div>
        <el-table
          :data="CompData.CompTableData"
          stripe
          border
          height="400"
          style="width: 100%;font-size: 10px"
          :header-cell-style="{'text-align':'center'}"
          :row-style="{height:'40px'}"
          :cell-style="{'text-align':'center',padding:'0px'}"
          ref="todoListRef"
          @row-click="handleRow2"
          @selection-change="handleSelectionChange2"
        >
          >
          <el-table-column label width="35">
            <template slot-scope="scope">
              <el-radio :label="scope.row" v-model="CompData.selectComp">&nbsp;</el-radio>
            </template>
          </el-table-column>

          <el-table-column prop="id" width="80" label="成分ID"></el-table-column>
          <el-table-column prop="allerName" label="成分名称"></el-table-column>
        </el-table>
        <!-- <el-pagination background layout="prev, pager, next" :total="1000"></el-pagination> -->
        <div class="dialogBlock">
          <el-pagination
            @size-change="handleSizeChange2"
            @current-change="handleCurrentChange2"
            current-page.sync="1"
            :page-size="100"
            layout="total, prev, pager, next"
            :total="CompData.total"
          ></el-pagination>
        </div>
        <span slot="footer" class="dialog-footer">
          <div class="SortFoot">
            <el-button style="margin-right:8px" type="primary" size="small" @click="SelectComp()">确定</el-button>
            <el-button style="margin-right:8px" @click="CodeSelectVisible = false" size="small">取消</el-button>
          </div>
        </span>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import {
  getSysDrugList,
  getSysDrugOneData,
  getCompOnelist,
  updateDictDrugOne,
  addDictDrugOne,
  deleteDictDrugOne
} from "@/api/rad";
export default {
  data() {
    return {
      tableHeight: 250,
      queryInfo: {
        srm: "",
        pageList: 1,
        pageSize: 20
      },
      total: 0,
      dictDrugList: [],
      ShowOneDataVisible: false,
      Typeoptions: [
        {
          value: 8,
          label: "西药"
        },
        {
          value: 2,
          label: "中药"
        },
        {
          value: 6,
          label: "中成药"
        }
      ],
      InjectOptions: [
        {
          value: -1,
          label: "未知"
        },
        {
          value: 0,
          label: "否"
        },
        {
          value: 1,
          label: "是"
        }
      ],
      // 0-不属于TPN药品 1-脂肪乳 2-氨基酸 3-氨基酸+脂肪乳 4-糖
      // 5-糖+脂肪乳 6-糖+氨基酸 7-糖+氨基酸+脂肪乳
      TPNOptions: [
        {
          value: 0,
          label: "不属于TPN药品"
        },
        {
          value: 1,
          label: "脂肪乳"
        },
        {
          value: 2,
          label: "氨基酸"
        },
        {
          value: 3,
          label: "氨基酸+脂肪乳"
        },
        {
          value: 4,
          label: "糖"
        },
        {
          value: 5,
          label: "糖+脂肪乳"
        },
        {
          value: 6,
          label: "糖+氨基酸"
        },
        {
          value: 7,
          label: "糖+氨基酸+脂肪乳"
        }
      ],
      ShowOneData: {
        id: "",
        nameType: "",
        drugName: "",
        cbrand: "",
        genId: "",
        genName: "",
        formId: "",
        formName: "",
        formSearchCode: "",
        drugSpec: "",
        compId: "",
        compName: "",
        approvalCode: "",
        doseUnit: "",
        isSolvent: "",
        isInject: "",
        tpn: ""
      },
      multipleSelection: {},
      ShowDosageVisible: false,
      DosageData: {
        load: 0,
        srm: "",
        page: 1,
        pageSize: 20,
        DosageTableData: [],
        total: 0,
        selectDosage: ""
      },
      ShowCompVisible: false,
      CompData: {
        load: 0,
        srm: "",
        page: 1,
        pageSize: 20,
        CompTableData: [],
        total: 0,
        selectComp: ""
      },
      addDrugVisible: false,
      addDrugData: {
        nameType: "",
        drugName: "",
        cbrand: "",
        genId: "",
        genName: "",
        formId: "",
        formName: "",
        formSearchCode: "",
        drugSpec: "",
        compId: "",
        compName: "",
        approvalCode: "",
        doseUnit: "",
        isSolvent: "",
        isInject: "",
        tpn: ""
      }
    };
  },
  // 监听浏览器变化
  mounted: function() {
    this.$nextTick(function() {
      this.tableHeight =
        window.innerHeight - this.$refs.table.$el.offsetTop - 50;

      // 监听窗口大小变化
      let self = this;
      window.onresize = function() {
        self.tableHeight =
          window.innerHeight - self.$refs.table.$el.offsetTop - 50;
      };
    });
  },
  created: function() {
    this.getSysDrugList();
  },
  methods: {
    handleClose(done) {
      done();
    },
    // 监听pagesize改变的事件
    handleSizeChange(newSize) {
      this.queryInfo.pageSize = newSize;
      this.getSysDrugList();
      // console.log(newSize)
    },
    // 当前展示的页面
    handleCurrentChange(newPage) {
      this.queryInfo.pageList = newPage;
      this.getSysDrugList();
      // console.log(newPage)
    },
    handleSizeChange2(newSize) {
      this.CompData.pageSize = newSize;
      this.getCompOnelist();
    },
    handleCurrentChange2(newPage) {
      this.CompData.page = newPage;
      this.getCompOnelist();
    },
    handleSizeChange3(newSize) {
      this.DosageData.pageSize = newSize;
      this.getDosageOnelist();
    },
    handleCurrentChange3(newPage) {
      this.DosageData.page = newPage;
      this.getDosageOnelist();
    },
    showDrugOne(id) {
      this.ShowOneData.id = id;
      this.ShowOneDataVisible = true;
      this.getSysDrugOneData();
    },
    async getSysDrugOneData() {
      let res = await this.$rad.getSysDrugOneData({
        id: this.ShowOneData.id
      });
      console.log(res);
      this.ShowOneData.nameType = res.data.nameType;
      this.ShowOneData.drugName = res.data.drugName;
      this.ShowOneData.cbrand = res.data.cbrand;
      this.ShowOneData.genId = res.data.genId;
      this.ShowOneData.genName = res.data.genName;
      this.ShowOneData.formId = res.data.formId;
      this.ShowOneData.formName = res.data.formName;
      this.ShowOneData.formSearchCode = res.data.formSearchCode;
      this.ShowOneData.drugSpec = res.data.drugSpec;
      this.ShowOneData.compId = res.data.compId;
      this.ShowOneData.compName = res.data.compName;
      this.ShowOneData.approvalCode = res.data.approvalCode;
      this.ShowOneData.doseUnit = res.data.doseUnit;
      this.ShowOneData.isSolvent = res.data.isSolvent;
      this.ShowOneData.isInject = res.data.isInject;
      this.ShowOneData.tpn = res.data.tpn;
      console.log(this.ShowOneData);
    },
    async getSysDrugList() {
      let _this = this;
      let res = await this.$rad.getSysDrugList({
        srm: this.queryInfo.srm,
        page: this.queryInfo.pageList,
        pageSize: this.queryInfo.pageSize
      });
      this.total = res.total;
      this.dictDrugList = res.rows;
      console.log(res);
    },
    ShowDosage(load) {
      this.DosageData.load = load;
      this.ShowDosageVisible = true;
      this.getDosageOnelist();
    },
    async getDosageOnelist() {
      let res = await this.$rad.getDosageOnelist({
        srm: this.DosageData.srm,
        page: this.DosageData.page,
        pageSize: this.DosageData.pageSize
      });
      console.log(res);
      this.DosageData.DosageTableData = res.rows;
      this.DosageData.total = res.total;
    },
    handleRow(row) {
      console.log(row);
      this.DosageData.selectDosage = row;
      this.multipleSelection = row;
    },
    handleSelectionChange(val) {
      console.log(res);
      this.multipleSelection = val;
    },
    handleRow2(row) {
      console.log(row);
      this.CompData.selectComp = row;
      this.multipleSelection = row;
    },
    handleSelectionChange2(val) {
      console.log(res);
      this.multipleSelection = val;
    },
    SelectDoseID() {
      console.log(this.DosageData.selectDosage);
      if (this.DosageData.load == 1) {
        this.addDrugData.formId = this.DosageData.selectDosage.formId;
        this.addDrugData.formName = this.DosageData.selectDosage.formName;
        this.addDrugData.formSearchCode = this.DosageData.selectDosage.formSearchCode;
      } else if (this.DosageData.load == 2) {
        this.ShowOneData.formId = this.DosageData.selectDosage.formId;
        this.ShowOneData.formName = this.DosageData.selectDosage.formName;
        this.ShowOneData.formSearchCode = this.DosageData.selectDosage.formSearchCode;
      }
      this.ShowDosageVisible = false;
    },
    SelectComp() {
      if (this.CompData.load == 1) {
        this.addDrugData.genName = this.CompData.selectComp.allerName;
        this.addDrugData.genId = this.CompData.selectComp.id;
      } else if (this.CompData.load == 2) {
        this.ShowOneData.genName = this.CompData.selectComp.allerName;
        this.ShowOneData.genId = this.CompData.selectComp.id;
      }

      // console.log()
      this.ShowCompVisible = false;
    },
    ShowComp(load) {
      this.CompData.load = load;
      this.ShowCompVisible = true;
      this.getCompOnelist();
    },
    async getCompOnelist() {
      let res = await this.$rad.getCompOnelist({
        srm: this.CompData.srm,
        page: this.CompData.page,
        pageSize: this.CompData.pageSize
      });
      console.log(res);
      this.CompData.total = res.total;
      this.CompData.CompTableData = res.rows;
    },
    async updateDrugOne() {
      let res = await this.$rad.updateDictDrugOne({
        id: this.ShowOneData.id,
        nameType: this.ShowOneData.nameType,
        drugName: this.ShowOneData.drugName,
        cbrand: this.ShowOneData.cbrand,
        genId: this.ShowOneData.genId,
        formId: this.ShowOneData.formId,
        formName: this.ShowOneData.formName,
        formSearchCode: this.ShowOneData.formSearchCode,
        drugSpec: this.ShowOneData.drugSpec,
        compId: this.ShowOneData.compId,
        compName: this.ShowOneData.compName,
        approvalCode: this.ShowOneData.approvalCode,
        doseUnit: this.ShowOneData.doseUnit,
        isSolvent: this.ShowOneData.isSolvent,
        isInject: this.ShowOneData.isInject,
        tpn: this.ShowOneData.tpn
      });
      console.log(res);
      if (res.code == 1) {
        this.ShowOneDataVisible = false;
        this.getSysDrugList();
        return this.$message({
          type: "success",
          message: res.msg
        });
      } else {
        return this.$message({
          type: "error",
          message: res.msg
        });
      }
    },
    async addDrug() {
      let res = await this.$rad.addDictDrugOne({
        nameType: this.addDrugData.nameType,
        drugName: this.addDrugData.drugName,
        cbrand: this.addDrugData.cbrand,
        genId: this.addDrugData.genId,
        genName: this.addDrugData.genName,
        formId: this.addDrugData.formId,
        formName: this.addDrugData.formName,
        formSearchCode: this.addDrugData.formSearchCode,
        drugSpec: this.addDrugData.drugSpec,
        compId: this.addDrugData.compId,
        compName: this.addDrugData.compName,
        approvalCode: this.addDrugData.approvalCode,
        doseUnit: this.addDrugData.doseUnit,
        isSolvent: this.addDrugData.isSolvent,
        isInject: this.addDrugData.isInject,
        tpn: this.addDrugData.tpn
      });
      console.log(res);
      if (res.code) {
        this.addDrugVisible = false;
        this.getSysDrugList();
        return this.$message({
          type: "success",
          message: res.msg
        });
      } else {
        return this.$message({
          type: "error",
          message: res.msg
        });
      }
    },
    async deleteDictDrugOne(id) {
      let res = await this.$rad.deleteDictDrugOne({
        id: id
      });
      console.log(res);
      if (res.code == 1) {
        return this.$message({
          type: "success",
          message: res.msg
        });
      } else {
        return this.$message({
          type: "error",
          message: res.msg
        });
      }
    }
  }
};
</script>
<style scoped>
.SearchCard {
  height: 50px;
  font-size: 12px;
}
.SearchTitle {
  height: 50px;
  display: flex;
  justify-content: center;
  align-items: center;
  border-right: 1px solid #c2c2c2;
}
.SearchLable {
  height: 50px;
  display: flex;
  justify-content: center;
  align-items: center;
}
.TableCard {
  margin-left: 3px;
  margin-top: 2px;
}
.block {
  text-align: center;
  margin-top: 12px;
  margin-bottom: 12px;
}
.showOneData >>> .el-input-group--append {
  width: 185px;
}
.showOneData >>> .el-select {
  width: 185px;
}
.editDialog >>> .el-dialog__header {
  margin-bottom: 0px;
}
.editDialog >>> .el-dialog__body {
  padding-left: 0px;
  padding-right: 0px;
}
.addInput {
  height: 45px;
  display: flex;
  align-items: center;
}
.addInput >>> .el-input {
  width: 40%;
  margin-left: 8px;
}
.addInput >>> .el-button {
  margin-left: 8px;
}
.SortFoot {
  height: 50px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
}
</style>